package com.pengy.shengxian;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class MainView {

    @Autowired
    private ApplicationContext applicationContext;

    public Parent getRootNode() throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));
        fxmlLoader.setControllerFactory(applicationContext::getBean);
        Parent root = fxmlLoader.load();
        
        // 加载CSS样式表
        String cssPath = getClass().getResource("/css/styles.css").toExternalForm();
        root.getStylesheets().add(cssPath);
        
        return root;
    }
} 